﻿//Copyright (C) <2013>  <jonathan cleeve norton> All Rights Reserved 
//Contact jon.norton@fin-plus.co.uk website <http://www.fin-plus.co.uk/>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FinPlusCommon;


namespace FinPlusStructure
{
    public class FinPlusStructure
    {
        //adaptors
        public static IFinPlusFunction QuoteAdaptor(string QuoteSource, IFinPlusFunction ReceiveAction, IFinPlusFunction PublishAction)
        {
            var func = new Function("QuoteSource");
            func["QuoteSource"] = QuoteSource;
            func["ReceiveAction"] = ReceiveAction;
            func["PublishAction"] = PublishAction;
            return func;
        }

        public static IFinPlusFunction TradeAdaptor(string InstrumentType, IFinPlusFunction ReceiveQuoteAction, IFinPlusFunction ParseTradeAction, IFinPlusFunction ResponseAction)
        {
            var func = new Function("TradeAdaptor");
            func["InstrumentType"] = InstrumentType;
            func["ReceiveQuoteAction"] = ReceiveQuoteAction;
            func["ParseTradeAction"] = ParseTradeAction;
            func["ResponseAction"] = ResponseAction;
            return func;
        }

        //market making
        public static IFinPlusFunction Index(string Market, string Instrument, string BuySell, double Level, string Source, int Date)
        {
            var func = new Function("Index");
            func["Instrument"] = Instrument;
            func["BuySell"] = BuySell;
            func["Level"] = Level;
            func["Source"] = Source;
            func["Date"] = Date;
            return func;
        }

        public static IFinPlusFunction Rate(string Market, string Instrument, string BuySell, double Level, string Source, int Date)
        {
            var func = new Function("Rate");
            func["Instrument"] = Instrument;
            func["BuySell"] = BuySell;
            func["Level"] = Level;
            func["Source"] = Source;
            func["Date"] = Date;
            return func; 
        }

        public static IFinPlusFunction Price(string Market, string Instrument, string BuySell, double Level, string Source, int Date)
        {
            var func = new Function("Price");
            func["Instrument"] = Instrument;
            func["BuySell"] = BuySell;
            func["Level"] = Level;
            func["Source"] = Source;
            func["Date"] = Date;
            return func;
        }

        public static IFinPlusFunction Spread(string Market, string Instrument, string BuySell, double Level, string Source, int Date)
        {
            var func = new Function("Spread");
            func["Instrument"] = Instrument;
            func["BuySell"] = BuySell;
            func["Level"] = Level;
            func["Source"] = Source;
            func["Date"] = Date;
            return func;
        }

        public static IFinPlusFunction Setting(string IndexName, double Level, int Date)
        {
            var func = new Function("Setting");
            func["IndexName"] = IndexName;
            func["Level"] = Level;
            func["Date"] = Date;
            return func;
        }

        public static IFinPlusFunction Quote(string QuoteRef, string Instrument, string BuySell, double Quote, double Size, string QuoteStyle, string QuoteType, string RateType, string QuoteSource, string Counterparty) 
        {
            var func = new Function("Quote");
            func["QuoteRef"] = QuoteRef;
            func["Instrument"] = Instrument;
            func["BuySell"] = BuySell;
            func["Quote"] = Quote;
            func["Size"] = Size;
            func["QuoteStyle"] = QuoteStyle;
            func["QuoteType"] = QuoteType;
            func["RateType"] = RateType;
            func["QuoteSource"] = QuoteSource;
            func["Counterparty"] = Counterparty;
            return func; 
        }

        public static IFinPlusFunction QuoteInterest(string Instrument, string Book, bool IsAxe, string BuySell, double Quote, double Size, string QuoteStyle, string QuoteType, string QuoteMark, string RateType, string Trader)
        {
            var func = new Function("QuoteInterest");
            func["Instrument"] = Instrument;
            func["Book"] = Book;
            func["IsAxe"] = IsAxe;
            func["BuySell"] = BuySell;
            func["Quote"] = Quote;
            func["Size"] = Size;
            func["QuoteStyle"] = QuoteStyle;
            func["QuoteType"] = QuoteType;
            func["QuoteMark"] = QuoteMark;
            func["RateType"] = RateType;
            func["Trader"] = Trader;
            return func;
        }

        public static IFinPlusFunction QuoteCancel(string QuoteRef) 
        {
            var func = new Function("QuoteCancel");
            func["QuoteRef"] = QuoteRef;
            return func;
        }

        public static IFinPlusFunction QuoteExecute(string QuoteRef, double Size) 
        {
            var func = new Function("QuoteExecute");
            func["QuoteRef"] = QuoteRef;
            func["Size"] = Size;
            return func;
        }

        public static IFinPlusFunction QuoteStyle(string QuoteStyle) 
        {
            var func = new Function("QuoteStyle");
            func["QuoteStyle"] = QuoteStyle;
            return func;
        }

        public static IFinPlusFunction QuoteType(string QuoteType) 
        {
            var func = new Function("QuoteType");
            func["QuoteType"] = QuoteType;
            return func;
        }

        public static IFinPlusFunction QuoteMark(string QuoteMark)
        {
            var func = new Function("QuoteMark");
            func["QuoteMark"] = QuoteMark;
            return func;
        }

        public static IFinPlusFunction QuoteSource(string QuoteSource, string User, string Location) 
        {
            var func = new Function("QuoteSource");
            func["QuoteSource"] = QuoteSource;
            func["User"] = User;
            func["Location"] = Location;
            return func;
        }

        public static IFinPlusFunction CounterpartyQuoteTier(string Counterparty, string InstrumentType, double Adjustment)
        {
            var func = new Function("QuoteTier");
            func["Counterparty"] = Counterparty;
            func["InstrumentType"] = InstrumentType;
            func["Adjustment"] = Adjustment;
            return func;
        }

        public static IFinPlusFunction Instrument(string Instrument, string Ccy, string LinkedCurve, string InstrumentName, string InstrumentType, string RateType, double ChgMin, double SizeMin, double SizeMax, double ShockUnit) 
        {
            var func = new Function("Instrument");
            func["Instrument"] = Instrument;
            func["Ccy"] = Ccy;
            func["LinkedCurve"] = LinkedCurve;
            func["InstrumentName"] = InstrumentName;
            func["InstrumentType"] = InstrumentType;
            func["RateType"] = RateType;
            func["ChgMin"] = ChgMin;
            func["SizeMin"] = SizeMin;
            func["SizeMax"] = SizeMax;
            func["ShockUnit"] = ShockUnit;
            return func;
        }

        public static IFinPlusFunction InstrumentSpread(string Instrument, string SpreadName, string Spread, string SpreadType, bool IsMktToMkt, double BuyAdj, double SellAdj, double Weight, string Trader)
        {
            var func = new Function("InstrumentSpread");
            func["Instrument"] = Instrument;
            func["SpreadName"] = SpreadName;
            func["Spread"] = Spread;
            func["SpreadType"] = SpreadType;
            func["Weight"] = Weight;
            func["IsMktToMkt"] = IsMktToMkt;
            func["BuyAdj"] = BuyAdj;
            func["SellAdj"] = SellAdj;
            func["Trader"] = Trader;
            return func;
        }

        public static IFinPlusFunction InstrumentType(string InstrumentType)
        {
            var func = new Function("InstrumentType");
            func["InstrumentType"] = InstrumentType;
            return func;
        }

        public static IFinPlusFunction RateType(string RateType)
        {
            var func = new Function("RateType");
            func["RateType"] = RateType;
            return func;
        }

        public static IFinPlusFunction Ccy(string Ccy, string Name) 
        {
            var func = new Function("Ccy");
            func["Ccy"] = Ccy;
            func["Name"] = Name;
            return func;
        }

        public static IFinPlusFunction BuySell(string BuySell) 
        {
            var func = new Function("BuySell");
            func["BuySell"] = BuySell;
            return func;
        }

        public static IFinPlusFunction SpreadType(string SpreadType)
        {
            var func = new Function("SpreadType");
            func["SpreadType"] = SpreadType;
            return func;
        }

        public static IFinPlusFunction BizConv(string BizConv)
        {
            var func = new Function("BizConv");
            func["BizConv"] = BizConv;
            return func;
        }

        public static IFinPlusFunction DayCount(string DayCount)
        {
            var func = new Function("DayCount");
            func["DayCount"] = DayCount;
            return func;
        }

        public static IFinPlusFunction Holidays(string Holidays)
        {
            var func = new Function("Holidays");
            func["Holidays"] = Holidays;
            return func;
        }

        public static IFinPlusFunction Freq(string Freq)
        {
            var func = new Function("Freq");
            func["Freq"] = Freq;
            return func;
        }

        public static IFinPlusFunction PayRec(string PayRec)
        {
            var func = new Function("PayRec");
            func["PayRec"] = PayRec;
            return func;
        }

        public static IFinPlusFunction CurveName(string CurveName, string CurveType)
        {
            var func = new Function("CurveName");
            func["CurveName"] = CurveName;
            func["CurveType"] = CurveType;
            return func;
        }

        public static IFinPlusFunction CurveType(string CurveType)
        {
            var func = new Function("CurveName");
            func["CurveName"] = CurveType;
            return func;
        }

        //templates
        public static IFinPlusFunction VanillaSwapBuild(string Instrument, string CurveName, int SettlementDays, bool EndOfMonth, string Maturity, string Index, double Spread, string FixLegFrq, string FltLegFrq, string FixLegConv, string FltLegConv, string FixLegDayCount, string FltLegDayCount, string Holidays)
        {
            var func = new Function("VanillaSwapBuild");
            func["Instrument"] = Instrument;
            func["CurveName"] = CurveName;
            func["SettlementDays"] = SettlementDays;
            func["EndOfMonth"] = EndOfMonth;
            func["Maturity"] = Maturity;
            func["Index"] = Index;
            func["Spread"] = Spread;
            func["FixLegFrq"] = Index;
            func["FltLegFrq"] = Index;
            func["FixLegConv"] = Index;
            func["FltLegConv"] = Index;
            func["FixLegDayCount"] = Index;
            func["FltLegDayCount"] = Index;
            func["Holidays"] = Index;
            return func;
        }

        public static IFinPlusFunction ForwardRateAgreementBuild(string Instrument, string CurveName, int SettlementDays, string Start, string Maturity, string Index, string DayCount, string BizConv, string Holidays)
        {
            var func = new Function("ForwardRateAgreementBuild");
            func["Instrument"] = Instrument;
            func["CurveName"] = CurveName;
            func["SettlementDays"] = SettlementDays;
            func["Start"] = Start;
            func["Maturity"] = Maturity;
            func["Index"] = Index;
            func["DayCount"] = DayCount;
            func["BizConv"] = BizConv;
            func["Holidays"] = Holidays;
            return func;
        }

        public static IFinPlusFunction DepositLoanBuild(string Instrument, string CurveName, int SettlementDays, string Maturity, string Index, string DayCount, string BizConv, string Holidays)
        {
            var func = new Function("DepositLoanBuild");
            func["Instrument"] = Instrument;
            func["CurveName"] = CurveName;
            func["SettlementDays"] = SettlementDays;
            func["Maturity"] = Maturity;
            func["Index"] = Index;
            func["DayCount"] = DayCount;
            func["BizConv"] = BizConv;
            func["Holidays"] = Holidays;
            return func;
        }

        public static IFinPlusFunction ZCMBuild(string Instrument, string Maturity, int SettlementDays, string DayCount, string BizConv, string Holidays)
        {
            var func = new Function("ZCMBuild");
            func["Instrument"] = Instrument;
            func["Maturity"] = Maturity;
            func["SettlementDays"] = SettlementDays;
            func["BizConv"] = BizConv;
            func["Holidays"] = Holidays;
            return func;
        }

        public static IFinPlusFunction IRFutureBuild(string Instrument, string CurveName, int StartDate, int FutMonths, string DayCount, string BizConv, string Holidays)
        {
            var func = new Function("IRFutureBuild");
            func["Instrument"] = Instrument;
            func["CurveName"] = CurveName;
            func["StartDate"] = StartDate;
            func["FutMonths"] = FutMonths;
            func["DayCount"] = DayCount;
            func["BizConv"] = BizConv;
            func["Holidays"] = Holidays;
            return func;
        }

        public static IFinPlusFunction CreditDefaultSwapBuild(string Instrument, string CurveName, int SettlementDays, string Maturity, string PremFreq, string PremConv, string PayConv, string DayCount, string Holidays)
        {
            var func = new Function("CreditDefaultSwapBuild");
            func["Instrument"] = Instrument;
            func["CurveName"] = CurveName;
            func["SettlementDays"] = SettlementDays;
            func["Maturity"] = Maturity;
            func["PremFreq"] = PremFreq;
            func["PremConv"] = PremConv;
            func["PayConv"] = PayConv;
            func["Holidays"] = Holidays;
            return func;
        }

        public static IFinPlusFunction YieldCurveBuild(string CurveName, string Ccy, int NumDepo, int NumFut, int NumFra, int NumSwap, string Index, string DayCount, string Tolerance, string Holidays)
        {
            var func = new Function("YieldCurveBuild");
            func["CurveName"] = CurveName;
            func["Ccy"] = Ccy;
            func["NumDepo"] = Ccy;
            func["NumFut"] = NumFut;
            func["NumFra"] = NumFra;
            func["NumSwap"] = NumSwap;
            func["Index"] = Index;
            func["DayCount"] = DayCount;
            func["Tolerance"] = Tolerance;
            func["Holidays"] = Holidays;
            return func;
        }

        public static IFinPlusFunction DefaultCurveBuild(string CurveName, string Ccy, int NumSpread, string CreditName, double RecoveryRate, string DayCount, string Holidays)
        {
            var func = new Function("DefaultCurveBuild");
            func["CurveName"] = CurveName;
            func["Ccy"] = Ccy;
            func["NumSpread"] = NumSpread;
            func["CreditName"] = CreditName;
            func["RecoveryRate"] = RecoveryRate;
            func["DayCount"] = DayCount;
            func["Holidays"] = Holidays;
            return func;
        }

        public static IFinPlusFunction BondCurveBuild(string CurveName, string Ccy, int NumZCM, int NumBond, string DayCount, double Tolerance, string Holidays)
        {
            var func = new Function("CurveName");
            func["DayCount"] = DayCount;
            func["Tolerance"] = Tolerance;
            func["Holidays"] = Holidays;
            return func;
        }

        public static IFinPlusFunction IndexBuild(string IndexName, string CurveName, string IndexType, string Tenor)
        {
            var func = new Function("IndexBuild");
            func["IndexName"] = IndexName;
            func["CurveName"] = CurveName;
            func["IndexType"] = IndexType;
            func["Tenor"] = Tenor;
            return func;
        }

        //permissions
        public static IFinPlusFunction Permission(string User, string Name, string ItemName, string ItemValue, bool CanRead, bool CanWrite)
        {
            var func = new Function("Permission");
            func["User"] = User;
            func["Name"] = Name;
            func["ItemName"] = ItemName;
            func["ItemValue"] = ItemValue;
            func["CanRead"] = CanRead;
            func["CanWrite"] = CanWrite;
            return func;
        }

        //info
        public static IFinPlusFunction Application(string Application, string Description, string Owner)
        {
            var func = new Function("Application");
            func["Application"] = Application;
            func["Description"] = Description;
            func["Owner"] = Owner;
            return func;
        }

        //business structure
        public static IFinPlusFunction Location(string Location, string Country, string Region)
        {
            var func = new Function("Location");
            func["Location"] = Location;
            func["Country"] = Country;
            func["Region"] = Region;
            return func;
        }

        public static IFinPlusFunction Department(string Department, string Location)
        {
            var func = new Function("Department");
            func["Department"] = Department;
            func["Location"] = Location;
            return func;
        }

        public static IFinPlusFunction Desk(string Desk, string Department)
        {
            var func = new Function("Desk");
            func["Desk"] = Desk;
            func["Department"] = Department;
            return func;
        }

        public static IFinPlusFunction Book(string Book, string Desk, string Department, string Location)
        {
            var func = new Function("Book");
            func["Desk"] = Desk;
            func["Department"] = Department;
            func["Location"] = Location;
            return func;
        }

        public static IFinPlusFunction User(string User, string UserName, string Desk, string Location)
        {
            var func = new Function("User");
            func["User"] = User;
            func["UserName"] = UserName;
            func["Desk"] = Desk;
            func["Location"] = Location;
            return func;
        }

        //country structure
        public static IFinPlusFunction Region(string Region)
        {
            var func = new Function("Region");
            func["Region"] = Region;
            return func;
        }

        public static IFinPlusFunction Country(string Country, string Region)
        {
            var func = new Function("Country");
            func["Country"] = Country;
            func["Region"] = Region;
            return func;
        }

        //company structure
        public static IFinPlusFunction Counterparty(string Counterparty, string LongName, string Identifier, string DefaultCollateralCurve, string Country, string Sector, string Region, string InternalRating, string MoodysRating, string SnPRating)
        {
            var func = new Function("Counterparty");
            func["Counterparty"] = Counterparty;
            func["LongName"] = Counterparty;
            func["Identifier"] = Identifier;
            func["Country"] = Country;
            func["DefaultCollateralCurve"] = DefaultCollateralCurve;
            func["Sector"] = Sector;
            func["Region"] = Region;
            func["InternalRating"] = InternalRating;
            func["MoodysRating"] = MoodysRating;
            func["SnPRating"] = SnPRating;
            return func;
        }

        public static IFinPlusFunction Sector(string Sector)
        {
            var func = new Function("Sector");
            func["Sector"] = Sector;
            return func;
        }

        public static IFinPlusFunction InternalRating(string InternalRating, int Index)
        {
            var func = new Function("InternalRating");
            func["InternalRating"] = InternalRating;
            func["Index"] = Index;
            return func;
        }

        public static IFinPlusFunction MoodysRating(string MoodysRating, int Index)
        {
            var func = new Function("MoodysRating");
            func["MoodysRating"] = MoodysRating;
            func["Index"] = Index;
            return func;
        }

        public static IFinPlusFunction SnPRating(string SnPRating, int Index)
        {
            var func = new Function("SnPRating");
            func["SnPRating"] = SnPRating;
            func["Index"] = Index;
            return func;
        }

        //admin
        public static IFinPlusFunction FunctionMap(string Group, string Name)
        {
            var func = new Function("FunctionMap");
            func["Group"] = Group;
            func["Name"] = Name;
            return func;
        }
    }
}
